package com.qfedu.common;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Base64;

public class Md5 {

    public static String encrypt(String source){
        try {
            MessageDigest md = MessageDigest.getInstance("MD5");
            byte[] data = source.getBytes();
            byte[] result = md.digest(data);
            return Base64.getEncoder().encodeToString(result);
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
        }
        return "";
    }

    public static void main(String[] args) {
        System.out.println(encrypt("123456"));
    }

}
